home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / simcode.arc / SAVDIS.PAS < prev    next >
Pascal/Delphi Source File  |  1984-12-03  |  3KB  |  101 lines

  1. {$symtab-,$pagesize:84,$linesize:131,$debug-,
  2. $title:'SAVDIS.PAS -- Save - Display CRT Data'}
  3. {    COPYRIGHT @ 1982
  4.     Jim Holtman and Eric Holtman
  5.     35 Dogwood Trail
  6.     Randolph, NJ 07869
  7.     (201) 361-3395
  8. }
  9. {$mathck-}
  10.  
  11.  module save_display;
  12. {$include:'simterm.inc'}
  13. {$include:'graph.inc'}
  14.  
  15.     var
  16.        first_time : boolean;
  17.        one_line_save_area : string(160);
  18.        display_buffer_addr [external] : word;
  19.        bot_mem,top_mem : word;
  20.        next_ptr : ads of string(160);
  21.        retrace_flag [external] : boolean;
  22.        value first_time := TRUE;
  23.  
  24.     function xfreemem : word;
  25.  
  26.        external;
  27.  
  28.     function xmaxmem : word;
  29.  
  30.        external;
  31.  
  32.     procedure init;
  33.  
  34.        var
  35.       inc : word;
  36.  
  37.        begin
  38.       first_time := FALSE;
  39.       bot_mem := xfreemem;       {bottom of free memory}
  40.       top_mem := xmaxmem-10;   {top of free memory}
  41.       if top_mem < bot_mem then begin
  42.          next_ptr := ads one_line_save_area;
  43.                    {FAKE it}
  44.          bot_mem := next_ptr.s;
  45.          top_mem := bot_mem;
  46.          end
  47.       else begin
  48.          top_mem := bot_mem+((top_mem-bot_mem) div 10)*10;
  49.          next_ptr.r := 0;
  50.          next_ptr.s := bot_mem;
  51.          end;
  52.       while next_ptr.s <= top_mem do begin
  53.                    {blank at most 64K at a time}
  54.          next_ptr^[1] := ' ';  {blank out the buffer}
  55.          next_ptr^[2] := chr(7);
  56.          if (top_mem - next_ptr.s) > #FFF then inc := #FFF
  57.          else inc := top_mem - next_ptr.s + 10;
  58.                    {move the buffer on top of itself}
  59.          movesl(ads next_ptr^[1],ads next_ptr^[3],inc*16);
  60.          next_ptr.s := next_ptr.s+inc;
  61.          end;
  62.       next_ptr.s := bot_mem;
  63.       writeln(output,'Display Save Area = ',(top_mem-bot_mem) div 10,
  64.            ' lines.');
  65.       end;
  66.  
  67.     procedure save_line(line : CRT_SIZE;
  68.      inc : INC_LIMIT);
  69.  
  70.        var
  71.       display_buf : ads of char;
  72.  
  73.        begin
  74.       if first_time then init;
  75.       display_buf.s := display_buffer_addr;
  76.       display_buf.r := wrd(2*line*(RIGHT_MAR+1));
  77.       if retrace_flag then moves_wait(display_buf,next_ptr,LINE_SIZE)
  78.       else movesl(display_buf,next_ptr,LINE_SIZE);
  79.       next_ptr.s := next_ptr.s + wrd(10*inc);
  80.       if next_ptr.s < bot_mem then next_ptr.s := top_mem
  81.       else if next_ptr.s > top_mem then next_ptr.s := bot_mem;
  82.       end;
  83.  
  84.     procedure display_line(line : CRT_SIZE;
  85.      inc : INC_LIMIT);
  86.  
  87.        var
  88.       display_buf : ads of char;
  89.  
  90.        begin
  91.       if first_time then init;
  92.       display_buf.s := display_buffer_addr;
  93.       display_buf.r := wrd(2*line*(RIGHT_MAR+1));
  94.       if retrace_flag then moves_wait(next_ptr,display_buf,LINE_SIZE)
  95.       else movesl(next_ptr,display_buf,LINE_SIZE);
  96.       next_ptr.s := next_ptr.s + wrd(10*inc);
  97.       if next_ptr.s < bot_mem then next_ptr.s := top_mem
  98.       else if next_ptr.s > top_mem then next_ptr.s := bot_mem;
  99.       end;
  100.  end.
  101.